package view.user;


import common.RoomState;
import common.RoomTypes;
import model.room.Room;
import model.room.RoomCount;
import view.MyAbstractTableModel;

import java.time.LocalDate;
import java.util.ArrayList;

/**
 * @author mxd
 * @date 2024/5/26 0026
 */
//房间信息
public  class UserRoomTableModel extends MyAbstractTableModel<RoomCount> {

    public UserRoomTableModel(LocalDate startTime,LocalDate endTime){
        //初始化数据
        datas = new ArrayList<RoomCount>() ;
        datas.add(new RoomCount(RoomTypes.Single_ROOM,100.0,startTime, endTime));
        datas.add(new RoomCount(RoomTypes.Twin_ROOM,150.0,startTime, endTime));
        datas.add(new RoomCount(RoomTypes.Double_ROOM,200.0,startTime, endTime));
        datas.add(new RoomCount(RoomTypes.Deluxe_ROOM,399.0,startTime, endTime));
        //定义表头
        this.columnNames = new String[]{"房间类型","费用","剩余数量"};

    }


    @Override
    protected Object getProperty(Object obj, int columnIndex) {
        RoomCount c = (RoomCount) obj;
        Object result = "";
        switch (columnIndex) {
            case 0 :{
                switch (c.getRoomTypes()){
                    case Single_ROOM:
                        result = "单人间";
                        break;
                    case Double_ROOM:
                        result = "大床房";
                        break;
                    case Deluxe_ROOM:
                        result = "豪华间";
                        break;
                    case Twin_ROOM:
                        result = "双人间";
                        break;
                }
            } break ;
            case 1 :
                return c.getPrice();
            case 2:
                return c.getCount();
        }
        return result;
    }


}